﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Specialized;

public partial class fyshow : System.Web.UI.Page
{
    private NameValueCollection arg = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        arg = Request.Form;
        if (arg.Count == 0)
        {
            arg = Request.QueryString;
        }
        bindData();
    }

    private void bindData()
    {
        return;
        //层数
        int cengShu = int.Parse(arg["cengshu"]);
        //每层户数
        int huShu = int.Parse(arg["hushu"]);

        //根据楼号id查找单元
        DataTable dt = DbHelper.selectTable("danyuan","where p_id=" + arg["id"]);
        if (dt != null)
        {
            for(int i=0;i<dt.Rows.Count;i++)
            {
                DataRow dr = dt.Rows[i];
                danYuan.Text += "<table style=\"font-size: 10pt;float:left\" width=\""+100/dt.Rows.Count+"%\" bgcolor=\"#EFEFEF\" border=\"1\" bordercolor=\"#FFFFFF\" cellpadding=\"2\" cellspacing=\"4\">";
                danYuan.Text += getDanYuan(dr["showname"].ToString()); ;

                //根据单元id查找此单元下的住户
                DataTable huxing = DbHelper.selectTable("zhuhu","where p_id="+dr["id"]);
                if (huxing != null)
                {

                    for (int j = cengShu * huShu; j > 0; j--)
                    {
                        DataRow drr = huxing.Rows[i];
                        if (j % 2 == 0)
                        {
                            danYuan.Text += "<tr>";
                        }

                        danYuan.Text += getNum(
                            drr["id"].ToString(),
                            drr["showname"].ToString(),
                            drr["type"].ToString(),
                            drr["area"].ToString(),
                            drr["price"].ToString(),
                           (float.Parse(drr["price"].ToString()) / float.Parse(drr["area"].ToString())).ToString(),
                           int.Parse(drr["state"].ToString())
                           );


                        if ((j + 1) % 2 == 0)
                        {
                            danYuan.Text += "</tr>";
                        }

                    }
                }

                danYuan.Text += "</table>";
                
            }

        }
    }

    private string getDanYuan(string name)
    {
        return "<tr><td colspan=\"2\">" + name + "</td></tr>";
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="id">id</param>
    /// <param name="name">小区名</param>
    /// <param name="type">类型：两室一厅</param>
    /// <param name="size">面积</param>
    /// <param name="price">总价</param>
    /// <param name="sg">单价</param>
    /// <returns></returns>
    private string getNum(string id, string name, string type, string size, string price, string sg, int state)
    {
        string color = "";
        switch (state)
        {
            case 1: color = "#CCFFCC"; break;
            case 2: color = "#CCCCFF"; break;
            case 3: color = "#008080"; break;
            case 4: color = "#FFFF99"; break;
            case 5: color = "#FF6666"; break;
            case 6: color = "#33CCCC"; break;
        }
        return "<td onclick=\"window.open ('fyshowl.ASPX?name=" + name + "&id=" + id + "', 'contents');\" title=\"户型：" + type + "  面积：" + size + " 单价：" + sg + " 总价：" + price + "\" height=\"40\" bgcolor=\"" + color + "\">&nbsp;" + name + "</td>    ";
    }
}
